<%--
  Created by IntelliJ IDEA.
  User: 若兮
  Date: 2021/12/26
  Time: 16:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>部门分类</title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body  class="layui-anim layui-anim-downbit">
    <div class="layui-table-tool">
        <a type="button" href="adddept.jsp" style="text-decoration: none" class="layui-btn layui-inline"><i class="layui-icon layui-icon-addition"></i>添 加 部 门</a>
        <div class="layui-table-tool-self">
            <div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS"><i class="layui-icon layui-icon-cols"></i>
            </div>
            <div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT"><i
                    class="layui-icon layui-icon-export"></i>
            </div>
            <div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT"><i class="layui-icon layui-icon-print"></i>
            </div>
        </div>
    </div>
<form class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="100">
            <col width="150">
            <col width="120">
            <col width="150">
        </colgroup>
        <thead>
        <tr>
            <th>部门编号</th>
            <th>部门名称</th>
            <th>部门电话</th>
            <th>办公地点</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${requestScope.deptPg.list}" var="deptList">
            <tr>
                <td>${deptList.dno}</td>
                <td>${deptList.dName}</td>
                <td>${deptList.tel}</td>
                <td>${deptList.dPlace}</td>
                <td>
                    <a class="layui-btn layui-btn-xs" href="${pageContext.request.contextPath}/findDeptByDno?dno=${deptList.dno}">查看及编辑</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="return dept_del();" href="${pageContext.request.contextPath}/deleteDept?dno=${deptList.dno}">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <c:if test="${requestScope.deptPg.currentPage <= 1}">
        <button class="layui-btn layui-btn layui-btn-disabled" type="button">上一页</button>
    </c:if>

    <c:if test="${requestScope.deptPg.currentPage > 1}">
        <a href="${pageContext.request.contextPath}/showAllDeptByPage?currentPage=${requestScope.deptPg.currentPage-1}"
           class="layui-btn">上一页</a>
    </c:if>

    <c:if test="${requestScope.deptPg.currentPage >= requestScope.deptPg.totalPage}">
        <button class="layui-btn layui-btn layui-btn-disabled" type="button">下一页</button>
    </c:if>

    <c:if test="${requestScope.deptPg.currentPage < requestScope.deptPg.totalPage}">
        <a href="${pageContext.request.contextPath}/showAllDeptByPage?currentPage=${requestScope.deptPg.currentPage+1}"
           class="layui-btn">下一页</a>
    </c:if>

</form>
</body>
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-3.6.0.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
    function dept_del() {
        var msg = "真的要删除吗？";
        if (confirm(msg)===true){
            return true;
        }else {
            return false;
        }
    }
</script>
</html>
